home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-06 | 7.7 KB | 152 lines | [TEXT/CCL ] |
- ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ;@@@ Make
- ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ;
- ; These functions do a brain-damaged make: They don't ensure that required
- ; modules have been made, ie are up-to-date.
-
-
- ; check-make
- ;
- ; check-make takes a path (either a pathname (lisp or mac) or a string)
- ; and looks for a pair of files with paths identical to the argument,
- ; but with "lisp" and "fasl" as the types. If it finds them, it then
- ; compares their latest write dates: if the fasl is younger than the lisp,
- ; then return the mac-filename of the fasl and the lisp-filename of the lisp;
- ; but if the fasl is older than the lisp, then return the lisp-filename of both.
- ; If check-make can't find the lisp, then it returns the fasl's lisp-filename
- ; and nil. If it can't find the fals, then it returns the fasl's lisp-filename
- ; and the lisp's lisp-filename.
- ;
- ; In sum, two values are returned, whose types determine the appropriate
- ; action by make:
- ;
- ; The first is the fasl's filename: if a lisp pathname, then need to compile;
- ; if a mac filename, then don't need to compile.
- ;
- ; The second is the lisp's filename or nil: if nil, then couldn't find the
- ; source, can't make; if a lisp pathname, then can use it to make a fasl.
- ;
- (defun check-make (pn)
- (let* ((pathname (expand-logical-pathname
- (merge-pathnames pn *working-directory*)))
- (the-lisp-name (make-pathname :host (pathname-host pathname)
- :device (pathname-device pathname)
- :directory (pathname-directory pathname)
- :name (pathname-name pathname)
- :type "lisp"))
- (the-lisp-file (probe-file the-lisp-name))
- (the-fasl-name (make-pathname :host (pathname-host pathname)
- :device (pathname-device pathname)
- :directory (pathname-directory pathname)
- :name (pathname-name pathname)
- :type "fasl"))
- (the-fasl-file (probe-file the-fasl-name)))
- (if the-lisp-file
- (if the-fasl-file
- (if (> (file-write-date the-fasl-file) (file-write-date the-lisp-file))
- (values the-fasl-file the-lisp-name)
- (values the-fasl-name the-lisp-name))
- (values the-fasl-name the-lisp-name))
- (values the-fasl-name nil))))
-
- ; make-file
- ;
- ; make-file accepts a string, lisp-pathname, or mac-pathname and two optional arguments,
- ; check-p and temp-p. It determines whether the file pointed to by the path needs to
- ; be made, using check-make. If yes, then when check-p is false, or check-p is true
- ; and the user responds to a y-or-n-dialog with yes, compile the source. If temp-p is
- ; true send the fasl to the same name and directory as the source, but type "temp-fasl".
- ;
- ; Return two values: The first is t if the path has been made (either already ok,
- ; or new fasl compiled), or nil if the path needs still to be made. The second is
- ; the path to the source, which is a mac-pathname if a new file was created, a lisp-
- ; pathname if a new file was needed, but not created, and nil otherwise.
- ;
- (defun make-file (pn &optional check-p temp-p)
- (catch :cancel
- (multiple-value-bind (the-fasl the-lisp)
- (check-make (cond ((stringp pn)
- (expand-logical-namestring pn))
- ((pathnamep pn)
- (expand-logical-pathname pn))
- (t (error "The file must be either a string, a mac-pathname,~%~
- or a lisp-pathname, not ~a."
- pn))))
- (if (lisp-pathnamep the-fasl)
- (if (lisp-pathnamep the-lisp)
- (if (or (not check-p)
- (and check-p (y-or-n-dialog "The file ~a needs to be compiled.~%Do it now?"
- (mac-filename (mac-pathname the-fasl)))))
- (if temp-p
- (values t (compile-file the-lisp
- :output-file
- (make-pathname :host (pathname-host the-fasl)
- :device (pathname-device the-fasl)
- :directory (pathname-directory the-fasl)
- :name (pathname-name the-fasl)
- :type "temp-fasl")))
- (values t (compile-file the-lisp)))
- (values nil the-lisp))
- (values nil nil))
- (values t nil)))))
-
- ; make-directory
- ;
- ; make-directory takes the host, device, and directory components of the entered
- ; path (string, lisp, or mac) and applies make-file to each file of type "lisp" in
- ; the result. If make-directories second argument, check-p is non-nil, then make-
- ; file will check whether to make any files that need making. Finally, errors in
- ; compilation produce a dialog that asks whether the makes so far should be abandoned,
- ; thus returning the directory to its state before the make-directory call. If the
- ; response is yes, then the newly created fasls (all of type "temp-fasl", thanks to
- ; passing t as temp-p to make-file) are deleted. At the end of successfully
- ; making all the files, the created fasls are renamed with type "fasl".
- ;
- (defun make-directory (&optional (pn *working-directory*) check-p)
- (let* ((the-full-pn (cond ((stringp pn)
- (expand-logical-namestring pn))
- ((pathnamep pn)
- (expand-logical-pathname pn))
- (t (error "The file must be either a string, a mac-pathname,~%~
- or a lisp-pathname, not ~a."
- pn))))
- (the-directory
- (merge-pathnames (make-pathname :host (pathname-host the-full-pn)
- :device (pathname-device the-full-pn)
- :directory (pathname-directory the-full-pn))
- *working-directory*))
- (the-current-file nil)
- (the-intermediates nil))
- (unwind-protect
- (progn
- (do-files-in-directory (file-name the-directory
- (progn
- (setf the-current-file nil)
- (nreverse the-intermediates)))
- (setf the-current-file (mac-filename (mac-pathname file-name)))
- (when (string= (pathname-type file-name) "lisp")
- (multiple-value-bind (done file)
- (make-file file-name check-p t)
- (when (and done file)
- (push file the-intermediates)))))
- (mapc #'(lambda (f)
- (rename-file f (make-pathname :type "fasl") :overwrite t))
- the-intermediates))
- (when (and the-current-file
- (not (catch :cancel
- (y-or-n-dialog "Compilation failed on file ~a.~%~
- Do you wish to keep the successful compilations?"
- the-current-file))))
- (mapc #'(lambda (f)
- (delete-file f :error-if-no-exist nil :overwrite t))
- the-intermediates)))))
-
- ; make-require
- ;
- (defun make-require (m &optional (f m))
- (make-file f)
- (funcall #'require m f))
-
- (eval-when (load compile)
- (provide "make"))